﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class LoginLogDAO : BaseService
    {
        public IList<LoginLog> GetLoginLogListByPaging(int page, int pagesize)
        {
            string hql = " from LoginLog order by AddDate desc";
            try
            {
                return FindList<LoginLog>(hql, null, (page - 1) * pagesize, pagesize);
            }
            catch (Exception)
            {
                
                return null;
            }
        }
        public int GetLoginLogListByPaging()
        {
            string hql = "select count(*) from LoginLog ";
            try
            {
                return Convert.ToInt32(GetValue(hql));
            }
            catch (Exception)
            {

                return 0;
            }
        }
        public IList<LoginLog> GetLoginLogListByUser(int userid,int page, int pagesize)
        {
            string hql = " from LoginLog where UserId=" + userid + " order by AddDate desc";
            try
            {
                return FindList<LoginLog>(hql, null, (page - 1) * pagesize, pagesize);
            }
            catch (Exception)
            {

                return null;
            }
        }
        public int GetLoginLogListByUser(int userid)
        {
            string hql = " select count(*) from LoginLog where UserId=" + userid;
            try
            {
                return Convert.ToInt32(GetValue(hql));
            }
            catch (Exception)
            {

                return 0;
            }
        }
    }
}
